package com.ncu.sprotapp.Config;

import com.ncu.sprotapp.Interceptor.JwtInterceptor;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 所有请求都要token
        // 除了注册 登录  静态资源等exclude
        registry.addInterceptor(new JwtInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/front/user/reg")
                .excludePathPatterns("/images/**")
                .excludePathPatterns("/**/login");
    }

   /* @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //  http://localhost:8080/images/a.jpg  ==>  D:/images/a.jpg
        registry.addResourceHandler("/images/**") //虚拟url路径
                .addResourceLocations("file:D:/images/"); //真实本地路径
    }*/
}
